package pCloud.config;

import java.net.InetSocketAddress;

import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration;

public class PCloudDirectRequestConfig {
	public static final String SERVER = "server_address";
	public static final String QUERY = "query";
	public static final String COLUMNS = "columns";
	public static final String AGGREGATION = "aggregation";
	public static final String TABLE = "table";
	public static final String START_DATE = "start_date";
	public static final String END_DATE = "end_date";
	public static final String STEP = "step";
	public static final String SIZE = "size";
	
	static PropertiesConfiguration config;

	public static void init(String fileName) throws ConfigurationException {
		config = new PropertiesConfiguration(fileName);
	}

	public static String getQuery() {
		return config.getString(QUERY);
	}

	public static String getString(String field){
		return config.getString(field);
	}
	
	public static InetSocketAddress getServerAddress() {
		String[] s = config.getString(SERVER).split(" ");

		return new InetSocketAddress(s[0], new Integer(s[1]).intValue());
	}
	
}
